<style lang="scss" rel="stylesheet/scss">
    .j-choose-addr-pop {
        
    }
</style>
<template>
    <div class="j-choose-addr-pop">
        <van-popup v-model="showpop" position="bottom">
            <van-area :area-list="areaList" @cancel="showpop=false" @confirm="selectArea"/>
        </van-popup>
    </div>
</template>

<script>
    import areaList from 'utils/area'
    export default {
        components: {

        },
        props:['showpop'],
        computed: {
            
        },
        data () {
            return {
                areaList:'',
                selectArr: []
            }
        },
        beforeCreate () {
            
        },
        created () {
        },
        watch: {
            
        },
        mounted() {
            this.areaList = areaList
        },
        methods: {
            selectArea(arr) {
                console.log(arr)
                this.selectArr = arr.map(item => {
                    let obj = {}
                    obj.name = item.name
                    obj.id = item.code
                    return obj
                })
                this.showpop = false
                this.autoSetText()
            },
            autoSetText() {
                let arr = this.selectArr
                console.log(arr)
                sessionStorage.setItem('areap_id',arr[0].id)
                sessionStorage.setItem('areac_id',arr[1].id)
                sessionStorage.setItem('areax_id',arr[2].id)
                this.$emit('chooseAddrFn',this.selectFwType)
            }
        },
        
    }
</script>

